package src.entity;

import java.util.ArrayList;
import java.util.List;

public class User {
    private String account;
    private String password;
    private String avatar;
    private List<Habit> habits = new ArrayList<>();
    private List<Goal> goals = new ArrayList<>();
    private List<Achievement> achievements = new ArrayList<>();

    // 无参构造器（JSON反序列化需要）
    public User() {
    }

    // 有参构造器
    public User(String account, String password) {
        this.account = account;
        this.password = password;
    }

    // Getter & Setter (JSON序列化需要getter方法)
    public String getAccount() { return account; }
    public void setAccount(String account) { this.account = account; }

    public String getPassword() { return password; }
    public void setPassword(String password) { this.password = password; }

    public String getAvatar() { return avatar; }
    public void setAvatar(String avatar) { this.avatar = avatar; }

    public List<Habit> getHabits() { return habits; }
    public void setHabits(List<Habit> habits) { this.habits = habits; }

    public List<Goal> getGoals() { return goals; }
    public void setGoals(List<Goal> goals) { this.goals = goals; }

    public List<Achievement> getAchievements() { return achievements; }
    public void setAchievements(List<Achievement> achievements) { this.achievements = achievements; }

    // 习惯管理方法
    public void addHabit(Habit habit) { habits.add(habit); }
    public void removeHabit(Habit habit) { habits.remove(habit); }

    // 目标管理方法
    public void addGoal(Goal goal) { goals.add(goal); }
    public void removeGoal(Goal goal) { goals.remove(goal); }

    // 成就管理方法
    public void addAchievement(Achievement achievement) { achievements.add(achievement); }

    @Override
    public String toString() {
        return "User{account='" + account + "', habits=" + habits.size() + "}";
    }
}